import useFileRenameExcelStore from '@renderer/store/Excel/FileRenameExcelStore'
import { storeToRefs } from 'pinia'
import { ref, watch } from 'vue'

const { form } = storeToRefs(useFileRenameExcelStore())

export default function useExcelTipImage() {
  const excelTipImg1 = ref(false)
  const excelTipImg2 = ref(false)
  const tipText = ref('')
  const handleImgDisplay = ref<() => void>()

  watch(
    () => form.value.importRenameMethod,
    (newVal) => {
      if (newVal === '0') {
        excelTipImg1.value = excelTipImg2.value
        excelTipImg2.value = false
        tipText.value = '查看顺序重命名表格填写示例'
        handleImgDisplay.value = excelTipImg1Fn
      } else {
        excelTipImg2.value = excelTipImg1.value
        excelTipImg1.value = false
        tipText.value = '查看匹配重命名表格填写示例'
        handleImgDisplay.value = excelTipImg2Fn
      }
    },
    { immediate: true }
  )

  function excelTipImg1Fn() {
    excelTipImg1.value = !excelTipImg1.value
  }

  function excelTipImg2Fn() {
    excelTipImg2.value = !excelTipImg2.value
  }

  return {
    excelTipImg1,
    excelTipImg2,
    handleImgDisplay,
    tipText
  }
}
